package pers.cz.commons.upload;

import cn.hutool.core.date.DateUtil;
import pers.cz.commons.operator.CommontOperator;
import pers.cz.mapper.FileUploadBusiMapper;
import pers.cz.model.FileUploadBusi;
import pers.cz.pub.BeanHelper;
import pers.cz.pub.CpublicFunc;
import pers.cz.spring.SpringContextUtil;

/**
 * 文件上传记录
 * @program: PostGirl-panent
 * @description: FileUploadLog
 * @author: Cheng Zhi
 * @create: 2021-11-17 17:30
 **/
public class FileUploadLog {

    /**
     * 插入文件上传记录表
     * @param fileName
     * @param userId
     * @return
     */
    public static Long insertFileUploadBusi(String fileName, Integer userId, String remarks) {
        BeanHelper beanHelper = SpringContextUtil.getBean(BeanHelper.class);
        CpublicFunc cpublicFunc  = new CpublicFunc(beanHelper);
        long soNbr = 0l;
        soNbr = cpublicFunc.getSoNbr();
        FileUploadBusi fileUploadBusi = new FileUploadBusi();
        fileUploadBusi.setSoNbr(soNbr);
        fileUploadBusi.setCreateDate(DateUtil.date());
        //String fileName = file.getOriginalFilename();
        fileUploadBusi.setFileName(fileName);
        fileUploadBusi.setType(0);
        String realName = CommontOperator.getOperator(userId).getRealName();
        fileUploadBusi.setUserName(realName);
        if (remarks != null) {
            fileUploadBusi.setExt1(remarks);
        }
        soNbr = SpringContextUtil.getBean(FileUploadBusiMapper.class).insert(fileUploadBusi);

        return soNbr;
    }

}
